<?php
/**
 * 描述：会员管理中心-证书列表。
 * @final
 */
final class Exec_MC_Licence_List extends Exec_MC_Master
{   
    public function Get()
    {
        $do=Functions::UrlArgs('do');
        switch($do)
        {
            case 'delete':
                $this->Get_Delete();
            break;
            default :
                $this->Get_List();
        }
    }

    /**
     * 描述：显示列表
     */
    public function Get_List()
    {
        #获取参数
        $sql='select * from licence where Account=? order by Datetime desc limit ?,15';
        $data=DB::PGetData($sql,array
        (
            Account::Session('Username')
        ));
        foreach($data['Record'] as $key=>$value)
        {
            $data['Record'][$key]['PictureLocation']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$data['Record'][$key]['PicturePath'];
        }
        if(!$data){
            return;
        }
        
        #渲染模板
        View::Assign('Licences',$data['Record']);
        View::Assign('PageMenu',PagerFactory::Create('Common')->Fetch($data,array('URL'=>'exec.php?action=mc_licence_list','IsDetail'=>TRUE)));
        $this->MasterPage_Display(View::Fetch('mc/licence/list.tpl'));
    }

    /**
     * 描述：删除信息。
     */
    public function Get_Delete()
    {
        #获取参数
        $id=Functions::UrlArgs('id');

        #执行操作
        DB::DeleteRowByID('licence','ID:'.$id);

        #跳转页面
        header('location:'.$_SERVER['HTTP_REFERER']);
    }

    /**
     * 描述：响应Post动作。
     */
    public function  Post()
    {
        #获取参数
        $id=Functions::FormArgs('ID');

        #执行操作
        foreach ($id as $value)
        {
            DB::DeleteRowByID('licence','ID:'.$value);
        }

        #跳转页面
        header('location:'.$_SERVER['HTTP_REFERER']);
    }
}
?>